/**
 * Copyright 2006 Brad Reynolds
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.leeloo.databinding.internal.ui;

import org.eclipse.core.runtime.IAdapterFactory;
import org.leeloo.core.TagService;
import org.leeloo.databinding.ui.test.support.PluginTestCase;
import org.leeloo.internal.core.ObjectDescriptor;

/**
 * Tests for the LabeledTreeNodeAdapterFactory. See each individual object for
 * tests for adapting objects.
 * 
 * @author Brad Reynolds
 */
public class LabeledTreeNodeAdapterFactoryTest extends PluginTestCase {
    IAdapterFactory factory = null;

    TagService tagService = null;

    protected void setUp() throws Exception {
        tagService = new TagService();
        factory = new LabeledTreeNodeAdapterFactory();
    }

    public void testGetAdapterList() throws Exception {
        Class[] adapterList = factory.getAdapterList();
        assertNotNull(adapterList);
        assertEquals(1, adapterList.length);
        assertEquals(ObjectDescriptor.class, adapterList[0]);
    }

    public void testGetObjectDescriptorLabeledTreeNodes() throws Exception {
        ObjectDescriptor descriptor = new ObjectDescriptor();
        
        LabeledTreeNode node = (LabeledTreeNode) descriptor.getAdapter(LabeledTreeNode.class);
        assertTrue(node.hasChildren());
        Object[] children = node.getChildren();
        assertNotNull(children);
        assertEquals(3, children.length);
    }
}